<?php
/*
 * Session variables:
 * $_SESSION['database'] [string] = database name of the current tutorial centre
 * $_SESSION['type'] [string] = user type of the logged in user
 * $_SESSION['authorised'] [boolean] = whether or not the current user is logged in
 * $_SESSION['user'] [string] = the username/ email of the logged in user 
 */
    session_start();

    if(isset($_SESSION['authorised']) && $_SESSION['authorised'] == true)
    {
        if(isset($_SESSION['type']))
        {
            if($_SESSION['type'] == 'administrator')
            {
                header('Location: admin_index.php');
                exit();
            }
            elseif($_SESSION['type'] == 'student')
            {
                header('Location: student_index.php');
                exit();
            }
            elseif($_SESSION['type'] == 'tutor')
            {
                header('Location: tutor_index.php');
                exit();
            }
            elseif($_SESSION['type'] == 'parent')
            {
                header('Location: parent_index.php');
                exit();
            }
        }
    }
    else
    {

?>

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Home</title>
        <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
        <style>
            .nav {
                  width:210px;
                  height:auto;
                  border:thin solid #09C;
                  margin-left: 10px;
                  text-align : center;}

            .mainline {
                  width:712px;
                  height:auto;
                  text-align : center;}
        </style>
    </head>

    <center>
    <body bgcolor="#FFFFFF">
        <div id="wrapper">
            <div id="header">
            <h1></h1>
            </div>

            <div id="header2">
                <h3></h3>
            </div>
            <div id="nav">
                <h4> Log in </h4>
                <table width="200" align="center">
                    <form action="authenticate.php" method="post">
                        <tr>
                            <td><b style="color:#069">Tutorial Centre:</b></td>
                        </tr>
                        <tr>
                            <td>
                                <select name="tcentre">';
                                <?php
								include('connect.inc');

                                $sql = "select * from databases order by tutorial_centre asc;";

                                $result = pg_query($sql);
                                for($i = 0; $i < pg_num_rows($result); $i++)
                                {
                                    $centrename = pg_fetch_result($result, $i, 'tutorial_centre');
                                    $centreid = "db".pg_fetch_result($result, $i, 'database_id');

                                    echo "<option value = \"$centreid\">$centrename</option>";
                                }
                                ?>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td><b style="color:#069">Username:</b></td>
                        </tr>
                        <tr>
                            <td><input name="username" type="text" size="25"/></td>
                        </tr>
                        <tr>
                            <td><b style="color:#069">Password:</b></td>
                        </tr>
                        <tr>
                            <td><input name="password" type="password" size="25" /></td>
                        </tr>
                        <tr>
                            <td><input name="submit" type = "submit" value ="Login" /></td>
                        </tr>
                    </form>
                </table>

                <br />

                <h4> Want one? </h4>
                <center>
                    <script src="homejs.js" type="text/javascript"></script><noscript><OBJECT id="homeobj" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH=225 HEIGHT=50> <PARAM NAME=movie VALUE="home.swf"> <PARAM NAME=menu VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=wmode VALUE=opaque> <param name="scale" value="noscale" /> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="home.swf" menu=false quality=high scale="noscale" wmode=opaque bgcolor=#FFFFFF  WIDTH=225 HEIGHT=50 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></OBJECT></noscript>
                </center>

                <br />
            </div>

            <div id="mainline">
                <h4>Welcome to TBMS</h4>
            </div>

            <div id="body">
                <h1>Tutorial Business Manager</h1>
                <div align="justify">
                <table width = "705" align="right">
                    <tr>
                        <td width = "400" valign = "top">
                            <script>var slide1foldername='';</script>
                            <script charset="utf-8" src="slide1.js" type="text/javascript"></script>
                        </td>
                        <td>This software aims to help Tutorial Centers manage their records of students. It also aims to provide a systematic student information system and payroll system. The software is designed to assist in the operations of a simple, generic tutorial center. It is up to the developers of the user’s tutorial center to add or remove any feature to tailor-fit the software to their needs.for tutorial centers. <br /><br />
                            <b>Features:</b><br />
                            <ul>
                                <li>Database of tutors and tutees (profiles and performance)</li>
                                <li>attendance record (time in/out)</li>
                                <li>Downloadable materials for tutors</li>
                                <li>Graphical User Interface</li>
                            </ul>
                        </td>
                    </tr>
                </table>
            </div>

            <p align="justify"><br /></p>
        </div>

        <br class="clearfloat" /><br />

        <div id="footer">
            <p align="center">
                Tutorial Business Manager: info@tbms.com <br />Credits/Engineers: Aquino, Chloebelle; Dela Cruz, Roy Erwin; Maliwanag, Ranyel Bryan; Manzano, Audrey Ann; Ng, Sheila Regine<br /><br />
                copyright 2011
            </p>
        </div>
        </div>
    </body>
    </center>
</html>
<?php

}

?>



